package com.guoheng.hazard.sys.controller.entpr;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.entpr.EntprProductionDeviceInsertDTO;
import com.guoheng.hazard.sys.model.dto.entpr.EntprProductionDeviceUpdateDTO;
import com.guoheng.hazard.sys.service.entpr.EntprProductionDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 类功能描述:　生产装置信息表
 *
 * @author fbl
 * @date 2019-11-13 09:42
 */
@RestController
@Validated
@Api(value = "生产装置信息表")
public class EntprProductionDeviceController {

    @Resource
    EntprProductionDeviceService entprProductionDeviceService;

    @ApiOperation(value = "查询企业生产装置信息")
    @GetMapping(value = "data/basic/enterprise/devices")
    public Result getDevices(Long entprId, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return entprProductionDeviceService.getDevices(entprId, pageNum, pageSize);
    }

    @ApiOperation(value = "修改企业生产装置信息")
    @PutMapping(value = "data/basic/enterprise/devices")
    public Result updateDevice(@RequestBody @Valid EntprProductionDeviceUpdateDTO entprProductionDeviceUpdateDTO) {
        return entprProductionDeviceService.updateDevice(entprProductionDeviceUpdateDTO);
    }

    @ApiOperation(value = "新增企业生产装置信息")
    @PostMapping(value = "data/basic/enterprise/devices")
    public Result insertDevice(@RequestBody @Valid EntprProductionDeviceInsertDTO entprProductionDeviceInsertDTO) {
        return entprProductionDeviceService.insertDevice(entprProductionDeviceInsertDTO);
    }

    @ApiOperation(value = "删除企业生产装置信息")
    @DeleteMapping(value = "data/basic/enterprise/devices/{id}")
    public Result deleteDevice(@PathVariable @NotNull Long id) {
        return entprProductionDeviceService.deleteDevice(id);
    }

    @ApiOperation(value = "查询企业生产装置详细信息")
    @GetMapping(value = "data/basic/enterprise/devices/{id}")
    public Result getDeviceById(@PathVariable @NotNull Long id) {
        return entprProductionDeviceService.getDeviceById(id);
    }

}